//
//  DesignSideOrderDetailVC.m
//  ForestPack
//
//  Created by jimmy on 2018/7/24.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#pragma mark - 1.设计端比稿评价详情界面  2.设计端计件评价详情界面
#import "DesignSideOrderDetailVC.h"
#import "OrderDetailFirstCell.h"
#import "DesignSideCountCell.h"
#import "OrderDetailHeaderView.h"


@interface DesignSideOrderDetailVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)  BaseTableView  * tableView;

@end

@implementation DesignSideOrderDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setTitle:@"订单详情"];
    [self setTableViewUI];
    
}

-(void)setTableViewUI
{
    self.tableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT) style:UITableViewStyleGrouped];
    self.tableView.estimatedRowHeight = 0;
    self.tableView.estimatedSectionHeaderHeight = 0;
    self.tableView.estimatedSectionFooterHeight = 0;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
}

#pragma mark - tableView的delegate和datasource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 3) {
        
        return 6;
    }
    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 108;
    }else if (indexPath.section == 1){
        return 60;
    }else if(indexPath.section == 2){
        return 130;
    }else{
        return 44;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0 || section == 2) {
        return 0.01;
    }else{
        return 44;
    }
    
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0 || section == 2) {
        UIView *view = [[UIView alloc] init];
        return view;
    }else if(section == 1){
        UIView *view = [[UIView alloc] init];
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(13, 10, 80, 24);
        label.text = @"奖金";
        label.textAlignment = NSTextAlignmentLeft;
        label.font = Kfont(14);
        label.textColor = FONTCOLOR_BLACK;
        [view addSubview:label];
        UILabel *lineLabel = [[UILabel alloc] init];
        lineLabel.frame = CGRectMake(0, 43, SCREEN_WIDTH, 1);
        lineLabel.backgroundColor = LineColor;
        [view addSubview:lineLabel];
        view.backgroundColor = [UIColor whiteColor];
        return view;
    }else{
        BiddingPeopleCountView *view = [BiddingPeopleCountView headerViewWithHeight:44];
        view.backgroundColor = [UIColor whiteColor];
        return view;
    }
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section == 3) {
        return 300;
    }
    return 10;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if (section == 3) {
        //        if (完成付款待评价界面) {
        //            UIView *view = [[UIView alloc] init];
        //            return view;
        //        }
        UIView *view = [[UIView alloc] init];
        OperateButton *button = [OperateButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(13, 50, SCREEN_WIDTH - 26, 44);
        [button setTitle:@"投稿" forState:UIControlStateNormal];
        [view addSubview:button];
        view.backgroundColor = [UIColor whiteColor];
        return view;
    }
    UIView *view = [[UIView alloc] init];
    return view;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        OrderDetailFirstCell *cell = [OrderDetailFirstCell cellWithTableView:tableView indexPath:indexPath];
        return cell;
    }else if (indexPath.section == 1){
        RinkingCell *cell = [RinkingCell cellWithTableView:tableView indexPath:indexPath];
        return cell;
    }else if(indexPath.section == 2){
        OrderInfoCell *cell = [OrderInfoCell cellWithTableView:tableView indexPath:indexPath];
        return cell;
    }else{
        BiddingPeopleCountCell *cell = [BiddingPeopleCountCell cellWithTableView:tableView indexPath:indexPath];
        return cell;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:false];
}

@end
